//
//  UserShare.m
//  HoldTheDoll
//
//  Created by 了赢 on 2018/5/21.
//  Copyright © 2018年 liaoying. All rights reserved.
//

#import "UserShare.h"

@implementation UserShare



+ (instancetype)shareInstance{
    
    static id instance;
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        
        instance = [[self alloc] init];
        
    });
    
    
    return instance;
}

#pragma mark——————————登录或注册找回密码等 得到数据后 赋值等操作
+ (void)dataWithModel:(id)responseObject{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        //保存模型
        // Encoding
        _userModel = [UserModel mj_objectWithKeyValues:responseObject];
        
        BOOL archiverType =  [NSKeyedArchiver archiveRootObject:_userModel toFile:_userModelFile];
        
        
        if(archiverType)
        {
            NSLog(@"归档成功");
        }
        [[NSNotificationCenter defaultCenter] postNotificationName:_UserDataSaveNotifi object:nil];
    });
    
}
#pragma mark——————————退出登录
+ (void)outLogin:(id)responseObjec{
    //清楚保存的用户数据
    _userModel = [UserModel new];
    //发送通知
    [[NSNotificationCenter defaultCenter] postNotificationName:_outLogin object:nil];
    
    [NSKeyedArchiver archiveRootObject:[UserModel new] toFile:_userModelFile];
    
}

@end
